All Questions
50 questions
-2votes
1answer
679views
grep to find an exact word match with a period in it
I have a huge .csv file in this format: "acc","lineage" "MT993865","B.1.509" "MW483477","B.1.402" "MW517757","B.1.2" &...
0votes
2answers
248views
Check for line in text bash
This is a really stupid question but I can't find an answer anywhere. So I have a command that prints out lines of text like this: htop kvantum alacritty And I need to check for a line, not a ...
-1votes
2answers
138views
Get number string as output from a paragraph string
I have a output stored in a variable that comes from a .jar script Token is: XYZ123 Not found in page: 0 Not found in page: 1 Not found in page: 2 Found with ID : #14214733 Now I want to extract the ...
3votes
2answers
5kviews
"grep -q" vs "if [ -n/-z]"
Hi I have a small wrapper script for NetworkManager which works with dmenu, I want it to be as simple as possible and hopefully fully posix. I'm using shellcheck and it gives me a "warnig" ...
1vote
2answers
1kviews
Searching a file for a string in an array
I am trying to check if items in an array options are in a file $file using the following simplified code: options=( A B C ) for i in "${options[@]}"; do if grep -F $file &...
1vote
3answers
2kviews
Slow performance of zgrep in multiple files
I have a 9.8GB gzip file A.gz and other file i have is 79MB B.txt which has some text in each line. I want to grep B's text in A.gz and write to a new file. Initially, I used this command zgrep -f B....
0votes
2answers
248views
Bash scripting loop concatenate pipes / redirections based from names variable
I have a command that produces a number of output lines that I later grep searching for. Based on a past answer I know I can use a single long command and do all my filters concurrently: https://...
1vote
1answer
864views
Using grep to associate ttl in ping command with operating system
Currently I'm looking into scripting and was writing something that will ping devices on a network, state if its reachable, and then take the ttl data from the ping and stating it's operating system. ...
-2votes
1answer
391views
How to grep single quotes grep " ' "? [closed]
I'm smashing myself trying to grep single quotes, not a word within single quotes 'word', but " ' ' " cat file; . $servers->setValue(‘server’,’base’,array(‘dc=aulendil,dc=com’)) . and I want to ...
0votes
2answers
681views
Using grep and logical operators for pattern matching within shell script
Im trying to develop a script that finds a specific pattern in the output of the dig command running against a list of domains. To do this I'm using grep but having difficulty implementing this using ...
1vote
2answers
702views
grep from list of keywords
Over the past couple of days I've been trying to dig through directories of files to report on files containing key words. Through the help of other users showing me the correct syntax for grep and ...
1vote
3answers
80views
Extracting a single line containing the highest value in a given column from a text file from each consecutively numbered sub-group/family
Within my text file, I would like to take the line containing the highest value present in column 3, from each consecutively numbered family (i.e. family_1, family_2 etc.) from column 2 and input ...
2votes
1answer
2kviews
Use regex for file matching, not string matching
I'm trying to figure out how to use grep to search for for a specific string, (for the sake of simplicity) say "9", and I want to search for this, again for simplicity, on all files containing the ...
2votes
2answers
655views
find: exclude n different directories and m different files present at any level but include few files from some excluded directories
I want to recursively find all directories and files inside a path but want to exclude some other directories and files that match given patterns. I then want to execute further commands on the search ...
0votes
1answer
846views
How can I use grep in a loop and add new line of text each time to the same file?
I am trying to use grep in a loop and extract data from many files and then save them in a text file. Currently when I write grep sth > test.txt It writes it in the file test.txt, but when I run ...